/*
* Copyright 2025 NXP
* NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
* accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
* activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms.  If you do not agree to be bound by the applicable license
* terms, then you may not retain, install, activate or otherwise use the software.
*/

#include "events_init.h"
#include <stdio.h>
#include "lvgl.h"

#if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
#include "freemaster_client.h"
#endif


static void home_setting_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.page_setting, guider_ui.page_setting_del, &guider_ui.home_del, setup_scr_page_setting, LV_SCR_LOAD_ANIM_MOVE_LEFT, 200, 200, true, false);
        break;
    }
    default:
        break;
    }
}

static void home_calendar_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.page_calendar, guider_ui.page_calendar_del, &guider_ui.home_del, setup_scr_page_calendar, LV_SCR_LOAD_ANIM_MOVE_LEFT, 200, 200, true, false);
        break;
    }
    default:
        break;
    }
}

static void home_alerm_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.page_alerm, guider_ui.page_alerm_del, &guider_ui.home_del, setup_scr_page_alerm, LV_SCR_LOAD_ANIM_MOVE_LEFT, 200, 200, true, false);
        break;
    }
    default:
        break;
    }
}

void events_init_home (lv_ui *ui)
{
    lv_obj_add_event_cb(ui->home_setting, home_setting_event_handler, LV_EVENT_ALL, ui);
    lv_obj_add_event_cb(ui->home_calendar, home_calendar_event_handler, LV_EVENT_ALL, ui);
    lv_obj_add_event_cb(ui->home_alerm, home_alerm_event_handler, LV_EVENT_ALL, ui);
}

static void page_calendar_c_back_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.home, guider_ui.home_del, &guider_ui.page_calendar_del, setup_scr_home, LV_SCR_LOAD_ANIM_NONE, 100, 200, false, true);
        break;
    }
    default:
        break;
    }
}

void events_init_page_calendar (lv_ui *ui)
{
    lv_obj_add_event_cb(ui->page_calendar_c_back, page_calendar_c_back_event_handler, LV_EVENT_ALL, ui);
}

static void page_alerm_a_back_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.home, guider_ui.home_del, &guider_ui.page_alerm_del, setup_scr_home, LV_SCR_LOAD_ANIM_NONE, 100, 200, false, true);
        break;
    }
    default:
        break;
    }
}

static void page_alerm_alerm_add_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.page_alerm_add, guider_ui.page_alerm_add_del, &guider_ui.page_alerm_del, setup_scr_page_alerm_add, LV_SCR_LOAD_ANIM_MOVE_LEFT, 200, 200, false, false);
        break;
    }
    default:
        break;
    }
}

void events_init_page_alerm (lv_ui *ui)
{
    lv_obj_add_event_cb(ui->page_alerm_a_back, page_alerm_a_back_event_handler, LV_EVENT_ALL, ui);
    lv_obj_add_event_cb(ui->page_alerm_alerm_add, page_alerm_alerm_add_event_handler, LV_EVENT_ALL, ui);
}

static void page_alerm_add_ac_back_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.page_alerm, guider_ui.page_alerm_del, &guider_ui.page_alerm_add_del, setup_scr_page_alerm, LV_SCR_LOAD_ANIM_NONE, 100, 200, false, true);
        break;
    }
    default:
        break;
    }
}

void events_init_page_alerm_add (lv_ui *ui)
{
    lv_obj_add_event_cb(ui->page_alerm_add_ac_back, page_alerm_add_ac_back_event_handler, LV_EVENT_ALL, ui);
}

static void page_setting_s_back_event_handler (lv_event_t *e)
{
    lv_event_code_t code = lv_event_get_code(e);
    switch (code) {
    case LV_EVENT_CLICKED:
    {
        ui_load_scr_animation(&guider_ui, &guider_ui.home, guider_ui.home_del, &guider_ui.page_setting_del, setup_scr_home, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 100, 200, false, true);
        break;
    }
    default:
        break;
    }
}

void events_init_page_setting (lv_ui *ui)
{
    lv_obj_add_event_cb(ui->page_setting_s_back, page_setting_s_back_event_handler, LV_EVENT_ALL, ui);
}


void events_init(lv_ui *ui)
{

}
